package br.com.social.mobile.dao;

import javax.persistence.Query;

import org.apache.log4j.Logger;

import br.com.social.mobile.entities.GpsDevice;


public class GpsDeviceDAO extends GenericDAO<GpsDevice>{
	
	private Logger logger = Logger.getLogger(GpsDeviceDAO.class);
	
		public GpsDevice getByImei(Long nuImei) {
			try {
				createEntityManager();
				Query query = entityManager
						.createQuery("select p FROM GpsDevice p where p.nuImei= :nuImei");
				query.setParameter("nuImei", nuImei);

				return (GpsDevice) query.getSingleResult();
			} catch (Exception e) {
				logger.error(e);
				return null;
			}
			
		}	
				
		
 
}
